﻿using FluentValidation;
using WebCoreAPI.Identity;

namespace WebCoreAPI.FluentValidation
{
    public class MyUserValidation : AbstractValidator<MyUser>
    {
        public MyUserValidation() 
        {
            RuleFor(x => x.Email).NotNull().NotEmpty().EmailAddress().WithMessage("请输入正确的邮箱格式")
                .Must(e => e.EndsWith("@qq.com") || e.EndsWith("@163.com")).WithMessage("只支持QQ和163邮箱");
            RuleFor(x => x.UserName).NotEmpty().NotNull().Length(5,15).WithMessage("用户名不能为空");
            RuleFor(x => x.PhoneNumber).NotNull().Length(11).WithMessage("请输入正确的手机号");
        }
    }
}
